-
Notifications
You must be signed in to change notification settings - Fork 34
Add Null & Boxed Types Support #143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
CatarinaGamboa
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the nullness check, I think we need more cases, like what if we declare the var and it doesn't have a value?
There are full tools just for the nullness checking (e.g., NullAway https://github.com/uber/NullAway)
PS: this would be so much easier if it were 2 prs, one for null and one for boxed types -- the boxed types would be an easy squash and merge
| if (refinementFound == null) { | ||
| refinementFound = new Predicate(); | ||
| } | ||
| if (Utils.isBoxedType(localVariable.getType()) && !Utils.isNullLiteral(e)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this necessary? and why wouldnt we put a createNullEq in the "only declaration, no assignment"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- That's the case where we declare a variable of boxed type (e.g.
Integer) and it is not null, so it carries the refinement"_ != null" - I didn't consider uninitialized variables, should we handle that case?
|
This PR adds support for null checking in LiquidJava.
It also allows us to refine boxed types which previously were also not supported (
Integer,Boolean,Short,Long,FloatandDouble).Changes
Refinements Language
nullliteral to the grammarLiteralNullAST nodeTyping
nullcan be assigned to any non-primitive type_ != null, while the literalnullcarries the refinement_ == nullZ3 Translation
java.lang.Objectnullliterals are converted to the sort of the other operand to match both sortsjava.lang.Integer=>Int) to avoid errors like“Sorts java.lang.Integer and Int are incompatible"Simplification
s == -1 && s != nullsimplifies tos == -1instead of-1 != nullTesting